package com.pmcc.core.web;

import com.pmcc.core.entity.Employee;
import com.pmcc.core.service.EmployeeService;
import com.pmcc.core.vo.UserVo;
import com.pmcc.utils.AntdPage;
import com.pmcc.utils.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * Created by tomas on 18/4/9.
 */
@RestController()
@RequestMapping("api/v1/employees")
public class EmployeeController {

    @Autowired
    EmployeeService employeeService;

    /**
     * 获取登录人信息
     * @return
     */
    @GetMapping(value = "getEmployeeInfo")
    public Object getEmployeeInfo(String type){
        return employeeService.getEmployeeInfo(type);
    }

    @GetMapping(value = "queryByPage")
    public ResultBean queryByPage(AntdPage antdPage, Employee model){
        return employeeService.queryByPage(antdPage,model);
    }

    @PostMapping(value = "addEmployee")
    public ResultBean addEmployee(@RequestBody Employee employee){
        return employeeService.addEmployee(employee);
    }

    @PostMapping("editEmployee")
    public ResultBean editEmployee(@RequestBody Map map) {
        return employeeService.editEmployee(map);
    }

    @GetMapping("deleteEmployee")
    public ResultBean deleteEmployee(String id) {
        return employeeService.deleteEmployee(id);
    }

    /**
     * 重置密码为123456
     * @param employeeId
     * @return
     */
    @GetMapping("/resetPwd")
    public ResultBean resetPwd(String employeeId){
        return employeeService.resetPwd(employeeId);
    }

    /**
     * 修改密码
     * @param map   password：老密码    newPassword：新密码
     * @return
     */
    @PostMapping(value = "resetPassword")
    public ResultBean resetPassword(@RequestBody Map<String,String> map){
        return employeeService.resetPassword(map);
    }
}
